home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / PInterfaces / MachineExceptions.p < prev    next >
Encoding:
Text File  |  1998-02-12  |  5.8 KB  |  223 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        MachineExceptions.p
  3.  
  4.      Contains:    Processor Exception Handling Interfaces.
  5.  
  6.      Version:    Technology:    Mac OS 8
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1993-1998 by Apple Computer, Inc., all rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. }
  18. {$IFC UNDEFINED UsingIncludes}
  19. {$SETC UsingIncludes := 0}
  20. {$ENDC}
  21.  
  22. {$IFC NOT UsingIncludes}
  23.  UNIT MachineExceptions;
  24.  INTERFACE
  25. {$ENDC}
  26.  
  27. {$IFC UNDEFINED __MACHINEEXCEPTIONS__}
  28. {$SETC __MACHINEEXCEPTIONS__ := 1}
  29.  
  30. {$I+}
  31. {$SETC MachineExceptionsIncludes := UsingIncludes}
  32. {$SETC UsingIncludes := 1}
  33.  
  34. {$IFC UNDEFINED __MACTYPES__}
  35. {$I MacTypes.p}
  36. {$ENDC}
  37.  
  38.  
  39. {$PUSH}
  40. {$ALIGN POWER}
  41. {$LibExport+}
  42.  
  43. { Some basic declarations used throughout the kernel }
  44.  
  45. TYPE
  46.     AreaID = ^LONGINT;
  47. {$IFC TARGET_OS_MAC }
  48. { Machine Dependent types for PowerPC: }
  49.     MachineInformationPowerPCPtr = ^MachineInformationPowerPC;
  50.     MachineInformationPowerPC = RECORD
  51.         CTR:                    UnsignedWide;
  52.         LR:                        UnsignedWide;
  53.         PC:                        UnsignedWide;
  54.         CR:                        UInt32;
  55.         XER:                    UInt32;
  56.         MSR:                    UInt32;
  57.         MQ:                        UInt32;
  58.         ExceptKind:                UInt32;
  59.         DSISR:                    UInt32;
  60.         DAR:                    UnsignedWide;
  61.         Reserved:                UnsignedWide;
  62.     END;
  63.  
  64.     RegisterInformationPowerPCPtr = ^RegisterInformationPowerPC;
  65.     RegisterInformationPowerPC = RECORD
  66.         R0:                        UnsignedWide;
  67.         R1:                        UnsignedWide;
  68.         R2:                        UnsignedWide;
  69.         R3:                        UnsignedWide;
  70.         R4:                        UnsignedWide;
  71.         R5:                        UnsignedWide;
  72.         R6:                        UnsignedWide;
  73.         R7:                        UnsignedWide;
  74.         R8:                        UnsignedWide;
  75.         R9:                        UnsignedWide;
  76.         R10:                    UnsignedWide;
  77.         R11:                    UnsignedWide;
  78.         R12:                    UnsignedWide;
  79.         R13:                    UnsignedWide;
  80.         R14:                    UnsignedWide;
  81.         R15:                    UnsignedWide;
  82.         R16:                    UnsignedWide;
  83.         R17:                    UnsignedWide;
  84.         R18:                    UnsignedWide;
  85.         R19:                    UnsignedWide;
  86.         R20:                    UnsignedWide;
  87.         R21:                    UnsignedWide;
  88.         R22:                    UnsignedWide;
  89.         R23:                    UnsignedWide;
  90.         R24:                    UnsignedWide;
  91.         R25:                    UnsignedWide;
  92.         R26:                    UnsignedWide;
  93.         R27:                    UnsignedWide;
  94.         R28:                    UnsignedWide;
  95.         R29:                    UnsignedWide;
  96.         R30:                    UnsignedWide;
  97.         R31:                    UnsignedWide;
  98.     END;
  99.  
  100.     FPUInformationPowerPCPtr = ^FPUInformationPowerPC;
  101.     FPUInformationPowerPC = RECORD
  102.         Registers:                ARRAY [0..31] OF UnsignedWide;
  103.         FPSCR:                    UInt32;
  104.         Reserved:                UInt32;
  105.     END;
  106.  
  107.  
  108. { Exception related declarations }
  109.  
  110. CONST
  111.     kWriteReference                = 0;
  112.     kReadReference                = 1;
  113.     kFetchReference                = 2;
  114.     writeReference                = 0;                            {  Obsolete name }
  115.     readReference                = 1;                            {  Obsolete name }
  116.     fetchReference                = 2;                            {  Obsolete name }
  117.  
  118.  
  119. TYPE
  120.     MemoryReferenceKind                    = UInt32;
  121.     MemoryExceptionInformationPtr = ^MemoryExceptionInformation;
  122.     MemoryExceptionInformation = RECORD
  123.         theArea:                AreaID;
  124.         theAddress:                LogicalAddress;
  125.         theError:                OSStatus;
  126.         theReference:            MemoryReferenceKind;
  127.     END;
  128.  
  129.  
  130. CONST
  131.     kUnknownException            = 0;
  132.     kIllegalInstructionException = 1;
  133.     kTrapException                = 2;
  134.     kAccessException            = 3;
  135.     kUnmappedMemoryException    = 4;
  136.     kExcludedMemoryException    = 5;
  137.     kReadOnlyMemoryException    = 6;
  138.     kUnresolvablePageFaultException = 7;
  139.     kPrivilegeViolationException = 8;
  140.     kTraceException                = 9;
  141.     kInstructionBreakpointException = 10;
  142.     kDataBreakpointException    = 11;
  143.     kIntegerException            = 12;
  144.     kFloatingPointException        = 13;
  145.     kStackOverflowException        = 14;
  146.     kTaskTerminationException    = 15;
  147.     kTaskCreationException        = 16;
  148.  
  149. {$IFC OLDROUTINENAMES }
  150.     unknownException            = 0;                            {  Obsolete name }
  151.     illegalInstructionException    = 1;                            {  Obsolete name }
  152.     trapException                = 2;                            {  Obsolete name }
  153.     accessException                = 3;                            {  Obsolete name }
  154.     unmappedMemoryException        = 4;                            {  Obsolete name }
  155.     excludedMemoryException        = 5;                            {  Obsolete name }
  156.     readOnlyMemoryException        = 6;                            {  Obsolete name }
  157.     unresolvablePageFaultException = 7;                            {  Obsolete name }
  158.     privilegeViolationException    = 8;                            {  Obsolete name }
  159.     traceException                = 9;                            {  Obsolete name }
  160.     instructionBreakpointException = 10;                        {  Obsolete name }
  161.     dataBreakpointException        = 11;                            {  Obsolete name }
  162.     integerException            = 12;                            {  Obsolete name }
  163.     floatingPointException        = 13;                            {  Obsolete name }
  164.     stackOverflowException        = 14;                            {  Obsolete name }
  165.     terminationException        = 15;                            {  Obsolete name }
  166.     kTerminationException        = 15;                            {  Obsolete name }
  167.  
  168. {$ENDC}
  169.  
  170. TYPE
  171.     ExceptionKind                        = UInt32;
  172.     ExceptionInfoPtr = ^ExceptionInfo;
  173.     ExceptionInfo = RECORD
  174.         CASE INTEGER OF
  175.         0: (
  176.             memoryInfo:            MemoryExceptionInformationPtr;
  177.             );
  178.     END;
  179.  
  180.     ExceptionInformationPowerPCPtr = ^ExceptionInformationPowerPC;
  181.     ExceptionInformationPowerPC = RECORD
  182.         theKind:                ExceptionKind;
  183.         machineState:            MachineInformationPowerPCPtr;
  184.         registerImage:            RegisterInformationPowerPCPtr;
  185.         FPUImage:                FPUInformationPowerPCPtr;
  186.         info:                    ExceptionInfo;
  187.     END;
  188.  
  189.     ExceptionInformation                = ExceptionInformationPowerPC;
  190.     ExceptionInformationPtr             = ^ExceptionInformation;
  191.     MachineInformation                    = MachineInformationPowerPC;
  192.     MachineInformationPtr                 = ^MachineInformation;
  193.     RegisterInformation                    = RegisterInformationPowerPC;
  194.     RegisterInformationPtr                 = ^RegisterInformation;
  195.     FPUInformation                        = FPUInformationPowerPC;
  196.     FPUInformationPtr                     = ^FPUInformation;
  197.  
  198.     Note:    An ExceptionHandler is NOT a UniversalProcPtr.
  199.             It must be a PowerPC function pointer with NO routine descriptor. 
  200. }
  201. {$IFC TYPED_FUNCTION_POINTERS}
  202.     ExceptionHandler = FUNCTION(VAR theException: ExceptionInformationPowerPC): OSStatus; C;
  203. {$ELSEC}
  204.     ExceptionHandler = ProcPtr;
  205. {$ENDC}
  206.  
  207. { Routine for installing per-process exception handlers }
  208. FUNCTION InstallExceptionHandler(theHandler: ExceptionHandler): ExceptionHandler;
  209. {$ENDC}  {TARGET_OS_MAC}
  210.  
  211.  
  212. {$ALIGN RESET}
  213. {$POP}
  214.  
  215. {$SETC UsingIncludes := MachineExceptionsIncludes}
  216.  
  217. {$ENDC} {__MACHINEEXCEPTIONS__}
  218.  
  219. {$IFC NOT UsingIncludes}
  220.  END.
  221. {$ENDC}
  222.